<?php
/**
 * CookiesHelper.php class file.
 * @author wudg <544038230@qq.com>
 * @date 2020/10/29- 1:49 下午
 */

namespace common\helpers;


class CookiesHelper
{


    /**
     * 格式化cookie为数组
     * @param $cookiesStr
     * @return array
     */
    public static function formatCookies($cookiesStr):array
    {
        $cookieList = explode(';',$cookiesStr);
        $cookiesArr = [];
        foreach($cookieList as $cookie)
        {
            $tmpArr = explode('=',$cookie);
            $cookieKey = trim(array_shift($tmpArr));
            $cookieValue = implode('=',$tmpArr);
            $cookiesArr[$cookieKey] = $cookieValue;
        }
        return $cookiesArr;
    }
}